package com.whl215.kit.adapter.element

import com.whl215.kit.adapter.R

/**
 * author： happiness
 * date： 2021/4/15
 * description：
 */
class GrapeAction(var code: Int, var message: String,var placeHolder:Int) {
    companion object {
        const val LIST_LOADING: Int = 0
        const val LIST_EMPTY: Int = 1
        const val LIST_ERROR: Int = -1

        const val LOAD_MORE_BEGIN: Int = 0 // 开始加载
        const val LOAD_MORE_END: Int = 1 // 完成加载 但是还有数据
        const val LOAD_MORE_COMPLETION: Int = 2 // 完成加载没数据了
        const val LOAD_MORE_ERROR: Int = -2 // 加载失败 点击重新加载数据

        fun buildListLoadAction(message: String = "正在加载中...", placeHolder:Int = -1): GrapeAction {
            return GrapeAction(LIST_LOADING, message,placeHolder)
        }

        fun buildListEmptyAction(message: String = "没有查询到数据哦~", placeHolder:Int = R.drawable.grape_ic_cup): GrapeAction {
            return GrapeAction(LIST_EMPTY, message,placeHolder)
        }

        fun buildListErrorAction(message: String = "发生了一些错误", placeHolder:Int = R.drawable.grape_ic_clock): GrapeAction {
            return GrapeAction(LIST_ERROR, message,placeHolder)
        }

        /**
         * 开始加载数据
         */
        fun buildLoadMoreBeginAction(message: String = "正在加载中..."): GrapeAction {
            return GrapeAction(LOAD_MORE_BEGIN, message,-1)
        }

        /**
         * 加载完成还有数据
         */
        fun buildLoadMoreEndAction(): GrapeAction {
            return GrapeAction(LOAD_MORE_END, "加载完成",-1)
        }

        /**
         * 加载完成没有数据
         */
        fun buildLoadMoreCompletionAction(message: String = "已加载完全部数据"): GrapeAction {
            return GrapeAction(LOAD_MORE_COMPLETION, message,-1)
        }

        fun buildLoadMoreErrorAction(message: String = "发生了一些错误"): GrapeAction {
            return GrapeAction(LOAD_MORE_ERROR, message,-1)
        }
    }
}